
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "VisionGraph.h"

#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CMainFrame

IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
	ON_WM_CREATE()
	
	//ON_MESSAGE(XTPWM_PROPERTYGRID_NOTIFY, OnGridNotify)
	//ON_MESSAGE(XTPWM_DOCKINGPANE_NOTIFY, OnDockingPaneNotify)
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	if (!m_wndStatusBar.Create(this))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

	//GetDockingPaneManager()->InstallDockingPanes(this);
	//GetDockingPaneManager()->SetTheme(xtpPaneThemeOffice2003);
	//int nID = 1;
	//CXTPDockingPane* pPropertyPane = GetDockingPaneManager()->CreatePane(nID, CRect(0, 0,200, 120), xtpPaneDockRight);
	//pPropertyPane->SetTitle(_T("Properties"));
	//GetDockingPaneManager()->SetIcons(IDB_PANEICONS, &nID, 1);
	//XTPPaintManager()->RefreshMetrics();

	// Load the previous state for command bars.
	//LoadCommandBars(_T("CommandBars"));


	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CMDIFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CMDIFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG


LRESULT CMainFrame::OnGridNotify(WPARAM wParam, LPARAM lParam)
{
	//if (wParam == XTP_PGN_VERB_CLICK)
	//{
	//	CXTPPropertyGridVerb* pVerb = (CXTPPropertyGridVerb*)lParam;
	//	if (pVerb->GetID() == 1) OnCommand(ID_EDIT_PROPERTIES, 0);
	//	if (pVerb->GetID() == 2) OnCommand(ID_VIEW_PAPERCOLOR, 0);
	//	return TRUE;
	//}
	if (wParam == XTP_PGN_ITEMVALUE_CHANGED )
	{
		CXTPPropertyGridItem* pItem = (CXTPPropertyGridItem*)lParam;
		int inum = pItem->GetID();
		inum = 0;
		//switch (pItem->GetID())
		//{
		//	case ID_ITEM_AUTHOR: 
		//	{
		//		m_pView->GetDocument()->m_pSummInfo->SetAuthor(pItem->GetValue()); 
		//		break;
		//	}
		//	case ID_ITEM_SUBJECT:
		//	{
		//		m_pView->GetDocument()->m_pSummInfo->SetSubject(pItem->GetValue());
		//		break;
		//	}
		//	case ID_ITEM_TITLE: 
		//	{
		//		m_pView->GetDocument()->m_pSummInfo->SetTitle(pItem->GetValue()); 
		//		break;
		//	}
		//	case ID_ITEM_PENSIZE:
		//	{
		//		CDrawObj* pSelected = m_pView->m_selection.GetHead();

		//		int nPenSize = min(100, ((CXTPPropertyGridItemNumber*)pItem)->GetNumber());
		//		if (nPenSize > 0)
		//		{
		//			pSelected->m_logpen.lopnWidth.x = nPenSize;
		//			pSelected->m_logpen.lopnWidth.y = nPenSize;
		//		}
		//		pSelected->Invalidate();
		//		pSelected->m_pDocument->SetModifiedFlag();
		//		break;
		//	}
		//	case ID_ITEM_SOLID:
		//	{
		//		CDrawObj* pSelected = m_pView->m_selection.GetHead();

		//		BOOL bSolid = min(100, ((CXTPPropertyGridItemBool*)pItem)->GetBool());
		//		pSelected->m_bBrush = bSolid;
		//		pSelected->Invalidate();
		//		pSelected->m_pDocument->SetModifiedFlag();
		//		break;
		//	}
		//	case ID_ITEM_LINECOLOR:
		//	{
		//		COLORREF color = ((CXTPPropertyGridItemColor*)pItem)->GetColor();

		//		POSITION pos = m_pView->m_selection.GetHeadPosition();
		//		while (pos != NULL)
		//		{
		//			CDrawObj* pObj = m_pView->m_selection.GetNext(pos);
		//			pObj->SetLineColor(color);
		//		}
		//		break;
		//	}
		//	case ID_ITEM_FILLCOLOR:
		//	{
		//		COLORREF color = ((CXTPPropertyGridItemColor*)pItem)->GetColor();

		//		POSITION pos = m_pView->m_selection.GetHeadPosition();
		//		while (pos != NULL)
		//		{
		//			CDrawObj* pObj = m_pView->m_selection.GetNext(pos);
		//			pObj->SetFillColor(color);
		//		}
		//		break;
		//	}
		//	default:
		//	{
		//		TRACE(_T("Value Changed. Caption = %s, ID = %i, Value = %s\n"), 
		//			pItem->GetCaption(), pItem->GetID(), pItem->GetValue());
		//	}
		//}
	}
	return 0;
}